package test7;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2023-03-07
 * Time: 20:05
 */

public class SingletonTest07 {
    public static void main(String[] args) {
        Singleton instance = Singleton.INSTANCE;
        Singleton singleton = Singleton.INSTANCE;
        System.out.println(instance == singleton);

        instance.sayOK();
    }
}

//使用枚举也可以实现单例
enum Singleton{
    INSTANCE; //属性
    public void sayOK(){
        System.out.println("ok");
    }
}